package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.SystemMsg;
import cn.wolfcode.trip.base.mapper.SystemMsgMapper;
import cn.wolfcode.trip.base.query.SystemMsgQueryObject;
import cn.wolfcode.trip.base.service.ISystemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemServiceImpl implements ISystemService {
    @Autowired
    private SystemMsgMapper msgMapper;
    /**
     * 查询未读系统通知数量
     * @param userId
     * @return
     */
    @Override
    public int notSystems(Long userId) {
        return msgMapper.notSystems(userId);
    }

    @Override
    public void updateIsViewed(Long userId) {
        msgMapper.updateIsViewed(userId);
    }

    @Override
    public PageInfo<SystemMsg> query(SystemMsgQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
        List<SystemMsg> list = msgMapper.query(qo);
        return new PageInfo<SystemMsg>(list);
    }
}
